package com.mycode.command15.resolve3;

import java.io.*;
import java.util.List;

public class FileUtil {
    public static void writeCommands(List<Command> commandList) {
        try {
            FileOutputStream fileOutputStream = new FileOutputStream("config.log");
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(new BufferedOutputStream(fileOutputStream));
            objectOutputStream.writeObject(commandList);
            objectOutputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static List<Command> readCommands() {
        try {
            FileInputStream fileInputStream = new FileInputStream("config.log");
            ObjectInputStream objectInputStream = new ObjectInputStream(new BufferedInputStream(fileInputStream));
            List<Command> commandList = (List<Command>) objectInputStream.readObject();
            objectInputStream.close();
            return commandList;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
